package com.zzptc.sgz.shop.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class DBImpl extends DBI{
	private Connection conn;
	private final String URL="jdbc:mysql://localhost:3306/taotaobuy";
	private final String UNAME="root";
	private final String PWD="123456";
	private final String DRIVER="com.mysql.jdbc.Driver";
	
	public DBImpl(){
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
	}

	public static void main(String[] args) {
		DBImpl dbImpl = new DBImpl();
		try {
			System.out.println(dbImpl.getConn().isClosed());
		} catch (SQLException e) {
			e.printStackTrace();
		}

	}

	
	public Connection getConn() throws SQLException {

		conn = DriverManager.getConnection(URL, UNAME, PWD);
		return conn;
	}
	
	public void closeConn() throws SQLException {
		if(conn !=null && !conn.isClosed()){
			conn.close();
		}
	}

}
